﻿
@page "/Wms/BuyInWarehouseDetail/BatchEdit"
@using nERP.ViewModel.Wms.BuyInWarehouseDetailVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
  <div style="margin-bottom:10px;"> @WtmBlazor.Localizer["Sys.BatchEditConfirm"]</div>
  <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
    <BootstrapInput @bind-Value="@Model.LinkedVM.Seq"/>
    <Select @bind-Value="@Model.LinkedVM.BuyInWarehouseId" Items="AllBuyInWarehouses" Id="g151043e6f79e4501bfed948f8b5cf465"/>
    <Select @bind-Value="@Model.LinkedVM.WarehouseId" Items="AllWarehouses" Id="g4ccb451b96014335a4b054714d5f4294"/>
    <Select @bind-Value="@Model.LinkedVM.BuyId" Items="AllBuys" Id="g2d08efc80dd84aae8e3df14d0d5b0ded"/>
    <Select @bind-Value="@Model.LinkedVM.BuyDetailId" Items="AllBuyDetails" Id="g4032cb7383fe46b095bc177e681484e0"/>
    <Select @bind-Value="@Model.LinkedVM.GoodsId" Items="AllGoodss" Id="gefa937efdc154b16a8960da80332fc8c"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsName"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsSpec"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsUnit"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.BuyInNumber"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.Remark"/>
  </Row>

  <div class="modal-footer table-modal-footer">
    <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]"/>
    <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]"/>
  </div>

</ValidateForm>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private BuyInWarehouseDetailBatchVM Model = new BuyInWarehouseDetailBatchVM();
    private ValidateForm vform { get; set; }
    
    private async Task Submit(EditContext context)
    {
        Model.Ids = ids;
        await PostsForm(vform, "/api/Wms/BuyInWarehouseDetail/BatchEdit", (s) => WtmBlazor.Localizer["Sys.BatchEditSuccess", s], method: HttpMethodEnum.POST);
    }
            

    public void OnClose()
    {
        CloseDialog();
    }
    
    private List<SelectedItem> AllBuyInWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllBuys = new List<SelectedItem>();
    private List<SelectedItem> AllBuyDetails = new List<SelectedItem>();
    private List<SelectedItem> AllGoodss = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {
        
        
        AllBuyInWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyInWarehouseDetail/GetBuyInWarehouses");
        AllBuyInWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyInWarehouseDetail/GetWarehouses");
        AllWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllBuys = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyInWarehouseDetail/GetBuys");
        AllBuys.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllBuyDetails = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyInWarehouseDetail/GetBuyDetails");
        AllBuyDetails.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllGoodss = await WtmBlazor.Api.CallItemsApi("/api/Wms/BuyInWarehouseDetail/GetGoodss");
        AllGoodss.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });

        await base.OnInitializedAsync();
    }
}
